public class HourlyEmployee extends Employee {
    private double hourlyRate;
    private double hoursWorked;

    public HourlyEmployee(String name, String empId, double hourlyRate, double hoursWorked) {
        super(name, empId);
        this.hourlyRate = hourlyRate;
        this.hoursWorked = hoursWorked;
    }

    @Override
    public double calculateSalary() throws Exception {
        if (hoursWorked < 0 || hoursWorked > 168) {
            throw new Exception("工作时长异常，有效时长范围是0-168小时");
        }
        return hourlyRate * hoursWorked;
    }
}